package Lexical;

public enum Tag 
{
	// Identifiers
	IDENTIFIER			(false, null, 256),
	TYPE				(false, null, 256),
	NUMBER 				(false, null, 257),
	STRINGLITERAL		(false, null, 256),
	BOOL 				(false, null, 256),
	
	// Arithmetic and conditional operators 
	RELOP				(false, null, 258),		// ==, !=, <, <=, >, >=
	MULTDIVMOD			(false, null, 258),		// *, /, %
	SUMSUB				(false, null, 258),		// +, -
		
	
	/** RESERVED WORDS */
	// Instructions
	PROGRAM 			(true, "program", 0),
	FUNCTION 			(true, "function", 1),
	RETURNS				(true, "returns", 2),
	PROCEDURE			(true, "procedure", 3),
	IS					(true, "is", 4),
	RECORD				(true, "record", 5),
	ENDRECORD			(true, "endrecord", 6),
	BEGIN 				(true, "begin", 7),
	END					(true, "end", 8),
	
	// Conditionals
	IF 					(true, "if", 9),
	THEN 				(true, "then", 10),
	ELSIF				(true, "elsif", 11),
	ELSE 				(true, "else", 12),
	ENDIF 				(true, "endif", 13),	
	
	// Loops
	WHILE 				(true, "while", 14),
	LOOP 				(true, "loop", 15),
	ENDLOOP 			(true, "endloop", 16),
	
	// Boolean
	TRUE 				(true, "true", 17),
	FALSE 				(true, "false", 18),
	
	// Input and output
	INPUT 				(true, "input", 19),
	OUTPUT 				(true, "output", 20),
	
	// Logical operators
	AND 				(true, "and", 21),
	OR 					(true, "or", 22),
	NOT					(true, "not", 23),
		
	// Anything else
	SYMBOL				(false, null, -1);  
	
	
	/** METHODS AND PRIVATE ATTRIBUTES */
	private String name;
	private final boolean reserved;
	private int id;
	
	/**
	 * Constructor of a Tag.
	 * @param reserved a boolean value to identify if the Tag is reserved.
	 * @param name a string with the name of the Tag.
	 * @param id a int with the value of the id
	 */
	Tag (boolean reserved, String name, int id) 
	{ 
		this.reserved = reserved; 
		this.name = name; 
		if (reserved) {
			this.id = id + 259;
		} else {
			this.id = id;
		}
	}
	
	/**
	 * Verifies if the Tag is reserved.
	 * @return
	 * True if it is reserved.
	 * False it it is not reserved.
	 */
	public boolean isReserved() 
	{ 
		return this.reserved; 
	}
	
	/**
	 * Gets the name of the Tag.
	 * @return
	 * The name of the Tag as a string.
	 */
	public String getName() 
	{ 
		return this.name;
	}
	
	public void setName(String n){
		this.name = n;
	}

	/**
	 * 
	 * @return the id value of the tag
	 */
	public int getId() {
		return id;
	}

	/**
	 * 
	 * @param id a value of the if of the tag
	 */
	public void setId(int id) {
		this.id = id;
	}
}
